<?php

class Public_RenderMarkupSuccessView extends BlogPublicBaseView
{
	public function executeHtml(AgaviRequestDataHolder $rd)
	{
		$this->setupHtml($rd, 'compact');
		$params = $rd->getParameters();

		$markup_text = $params['markup_text'];
		
        $user = $this->getContext()->getUser();
        $xhtml = '';
        if ($user->hasCredential('posts.write') && isset($params['markup_type'])
            && $params['markup_type'] === 'post') 
        {
            // render post markup
            $ro = $this->getContext()->getRouting();
            MarkupProcessor::setBaseUrl($ro->gen('root'));
            $xhtml = MarkupProcessor::renderPostText($markup_text);
        } else {
            // render comment markup
            $xhtml = MarkupProcessor::renderCommentText($markup_text);
        }
		$this->setAttribute('rendered_text', $xhtml);
	}
}

?>
